

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加修改</title>
    {include file="include/top"}
    <style>
        .layui-form-item .layui-input-inline{width: 80%;}
        #LAY_layedit_2{background: #fff;}
    </style>
</head>
<body>

<div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-app-form-tags" style="padding: 20px 0 0 0;">

    {include file="include/selectsearch" ctype='layui-form-item' title="分类" classname='cids' optionHtml='<?php echo isset($cids)?$cids:"";?>' }
    {include file="include/input" class2='layui-form-item' type='text' title="名称" name='title' value='<?php echo isset($data["title"])?$data["title"]:"";?>'}
    {include file="include/input" class2='layui-form-item' type='text' title="电话" name='mobile' value='<?php echo isset($data["mobile"])?$data["mobile"]:"";?>'}
    {include file="include/input" class2='layui-form-item' type='text' title="联系人" name='contacts' value='<?php echo isset($data["contacts"])?$data["contacts"]:"";?>'}
    {include file="include/input" class2='layui-form-item' type='number' title="下调比%" name='subPercent' value='<?php echo isset($data["subPercent"])?$data["subPercent"]:"";?>'}
    {include file="include/input" class2='layui-form-item' type='number' title="下调金额" name='subPrice' value='<?php echo isset($data["subPrice"])?$data["subPrice"]:"";?>'}
    <div class="layui-form-item">
        <label class="layui-form-label">下调说明</label>
        <div class="layui-input-inline">
            都为空采用系统默认 代理让利的百分比；下调金额的权重高于下调比例。
        </div>
    </div>

    {include file="include/input" class2='layui-form-item' type='text' title="订单推送" name='urlOrder' value='<?php echo isset($data["urlOrder"])?$data["urlOrder"]:"";?>'}
    {include file="include/input" class2='layui-form-item' type='text' title="油站推送" name='urlGas' value='<?php echo isset($data["urlGas"])?$data["urlGas"]:"";?>'}
    {include file="include/input" class2='layui-form-item' type='text' title="用户名" name='username' value='<?php echo isset($data["username"])?$data["username"]:"";?>'}
    {include file="include/input" class2='layui-form-item' type='text' title="key" name='key' value='<?php echo isset($data["key"])?$data["key"]:"";?>'}
    <div class="layui-form-item">
        <label class="layui-form-label">重置Key</label>
        <div class="layui-input-inline">
            <div  type="button" class="layui-btn" id="resetKey">点此重置</div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">结算模式</label>
        <div class="layui-input-inline">
            <select name="payType" lay-search="" lay-filter="payType" lay-search>
                <option value="0" <?php if(isset($data['payType']) && $data['payType']==0){ echo 'selected';}?>>预存扣费</option>
                <option value="1" <?php if(isset($data['payType']) && $data['payType']==1){ echo 'selected';}?>>后付日分账</option>
                <option value="2" <?php if(isset($data['payType']) && $data['payType']==2){ echo 'selected';}?>>后付月结</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-inline">
            <textarea id="content" name="content" lay-verify="content" autocomplete="off" class="layui-textarea" style="display: none;">{$data.content?$data.content:''}</textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-inline">
            <select disabled name="status" lay-search="" lay-filter="status" lay-search>
                <option value="0" <?php if(isset($data['status']) && $data['status']==0){ echo 'selected';}?>>正常</option>
                <option value="-1" <?php if(isset($data['status']) && $data['status']==-1){ echo 'selected';}?>>禁用</option>
            </select>
        </div>
    </div>
</div>

{include file="include/js"}
<script>

    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','form','layedit','upload'],function () {
        var $=layui.$;
        var form=layui.form;
        var upload = layui.upload
        var layedit = layui.layedit;
        $(function (){
            var key = $("input[name='key']").val()
            if(!key || key.length != 32){
                $("input[name='key']").val(generateSecretKey())
            }
        })
        $("#resetKey").click(function (){
            $("input[name='key']").val(generateSecretKey())
        })
        function generateSecretKey(length = 32) {
            const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
            let result = '';
            const charactersLength = chars.length;
            for (let i = 0; i < length; i++) {
                result += chars.charAt(Math.floor(Math.random() * charactersLength));
            }
            return result;
        }
        // 图片接口放到建立编辑器前面，否则无效
        layedit.set({
            uploadImage: {
                url: '/users/uploadimg', //接口url
                type: 'post' //默认post
            }
        });
        // 设置编辑器
        layedit.build('content', {
            height: 500 //设置编辑器高度
            ,background:"#ffffff"
        });

        var index = layedit.build('content'); //建立编辑器
        form.verify({ // 这里就是把富文本数据同步到<textarea>中
            content: function (value) {
                return layedit.sync(index);
            }
        });
    });
</script>
</body>
</html>